<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./jquery/jquery-1.12.4.min.js"></script>

<body>
    <!-- 总结数组遍历的方法 手写 -->
    <script>
        var arr = [1, 52, 'kk', 5];
        /* jquery的数组遍历 */
        $.each(arr, function (index) {
            console.log(index);
            console.log(arr[index]);
        })
        /* 对象遍历 */
        var obj = {
            name: '吉他小王子',
            detail: '吉他小王子是武烁又名武桑',
            height: '178cm',
            weight: '120斤',
            jump: function () {
                console.log('50米');
            }
        }
        $.each(obj, function (key, value) {
            console.log(key, value);
        })

        /* 去除首尾空格 */
        var str = '      frg4thyt     ';
        console.log('111' + str + '222');
        /* $.trim */
        console.log('111' + $.trim(str) + '222');

        /* 判断一个变量是否是数组 $.isArray   是数组返回true 不是数组返回false*/
        console.log($.isArray(arr));
        console.log($.isArray(obj));
        console.log($.isArray('4153'));

        /* 判断一个值是否是函数 ifFunction */
        var fun = function () {
            console.log('aa');
        }
        function foo() {
            console.log('bb');
        }
        console.log($.isFunction(fun));
        console.log($.isFunction(foo));
        console.log($.isFunction(obj));
        console.log($.isFunction(obj.jump));

        /* 判断数据类型  $.type() */
        var aa = '465132';
        var num = 8465132;
        console.log($.type(aa));
        console.log($.type(num));
        console.log($.type(obj));
        console.log($.type(arr));
        console.log($.type(foo));

        var json = '{"name":"wushuo","age":"18"}';
        console.log(JSON.parse(json));
        console.log($.parseJSON(json));
    </script>
</body>

</html>